<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="shortcut icon" href="images/icon.ico" type="/image/x-icon" />
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
    <link rel="stylesheet" href="css/main.css">
    <title>Overview - Orders Management Display System</title>
</head>
<body>
<main>

    <div class="d-flex flex-column flex-shrink-0 p-3 bg-light" data-bs-scroll="true" data-bs-backdrop="false" tabindex="-1" style="width: 20%;min-width: 150px">
        <a href="/" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto link-dark text-decoration-none">
            <span class="fs-4">Orders Management Display System</span>
        </a>
        <hr>
        <ul class="nav nav-pills flex-column mb-auto">
            <li class="nav-item">
                <a href="overview.html" class="nav-link active" aria-current="page">
                    Overviews
                </a>
            </li>
            <li>
                <a href="account.html" class="nav-link link-dark">
                    Accounts
                </a>
            </li>
            <li>
                <a href="manage.html" class="nav-link link-dark">
                    All Orders
                </a>
            </li>
            <li>
                <a href="query.html" class="nav-link link-dark">
                    Orders Query
                </a>
            </li>
            <li>
                <a href="echarts.html" class="nav-link link-dark">
                  Chart Display
                </a>
              </li>
            <li>
                <a href="file.html" class="nav-link link-dark">
                    File
                </a>
            </li>
        </ul>
        <hr>
        <div class="dropdown">
            <a href="#" class="d-flex align-items-center link-dark text-decoration-none dropdown-toggle" id="dropdownUser2" data-bs-toggle="dropdown" aria-expanded="false">
                 <strong id="user_name_text"></strong>
            </a>
            <ul class="dropdown-menu text-small shadow" aria-labelledby="dropdownUser2">
                <li><a class="dropdown-item" href="setting.html">Settings</a></li>
                <li><hr class="dropdown-divider"></li>
                <li class="dropdown-item" id="logout">
                    Logout
                </li>
            </ul>
            <script type="text/javascript">
                const logoutButton = document.getElementById('logout')
                logoutButton.addEventListener("click", function () {
                    const request = new XMLHttpRequest()
                    request.onreadystatechange = function () {
                        if (request.readyState === 4 && request.status === 200) {
                            const json = JSON.parse(request.responseText)
                            if (json.errorCode !== "00000") {
                                alert(json.message)
                            }
                            window.location.href = "/"
                        } else if (request.readyState === 4 && request.status !== 200) {
                            alert(request.status)
                        }
                    }

                    request.open("POST", "/api/user/logout", true)
                    request.send()
                })

                window.onload = function () {
                    sendCurrent()
                }

                function sendCurrent() {
                    const request = new XMLHttpRequest()
                    const usernameText = document.getElementById('user_name_text')
                    request.onreadystatechange = function () {
                        if (request.readyState === 4 && request.status === 200) {
                            const json = JSON.parse(request.responseText)
                            if (json.errorCode !== undefined) {
                                alert(json.message)
                                window.location.href = "/"
                                return
                            }
                            usernameText.innerHTML = json.username
                        } else if (request.readyState === 4 && request.status !== 200) {
                            alert(request.status)
                        }
                    }

                    request.open("POST", "/api/user/current", true)
                    request.send()
                }
            </script>
        </div>
    </div>
    <div class="d-flex flex-column p-4 flex-grow-1 allow-rolling">
        <h1 class="flex-row">Overview</h1>
        <hr>
        <h2>About the project</h2>
        <p>A Orders Management Display System based on Hive and Zookeeper.</p>
        <h2>Information</h2>
        <div class="d-flex flex-row card-group">
            <div class="flex-row card">
                <div class="card-body">
                    <h4 class="card-title">Users</h4>
                    <p class="card-text">Provide basic user management function.</p>
                    <div class="card-link">
                        <a href="account.html" class="btn btn-outline-primary">Manage Users</a>
                    </div>
                </div>
            </div>
            <div class="flex-row card">
                <div class="card-body">
                    <h4 class="card-title">Orders</h4>
                    <p class="card-text">Provide Orders management and other functions.</p>
                    <div class="card-link">
                        <a href="manage.html" class="btn btn-outline-primary">Manage Orders</a>
                    </div>
                </div>
            </div>
            <div class="flex-row card">
                <div class="card-body">
                    <h4 class="card-title">File</h4>
                    <p class="card-text">Provide the service of uploading and downloading data files.</p>
                    <div class="card-link">
                        <a href="file.html" class="btn btn-outline-primary">File</a>
                    </div>
                </div>
            </div>
        </div>
        <br>
        <h2>Data</h2>
        <div class="d-flex flex-row card-group">
            <div class="flex-row card">
                <div class="card-body">
                    <h4 class="card-title">All Users</h4>
                    <h2 class="card-text text-primary">5</h2>
                </div>
            </div>
            <div class="flex-row card">
                <div class="card-body">
                    <h4 class="card-title">Current Online</h4>
                </div>
            </div>
            <div class="flex-row card">
                <div class="card-body">
                    <h4 class="card-title">Orders</h4>
                </div>
            </div>
        </div>
    </div>
</main>

</body>
</html>
